#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

import random
import sys

word = sys.argv[1]

i = 0
while i < 10:
    randomnumber = random.randint(0, 2541)
    start = str(randomnumber * 10000 + 1)
    end = str((randomnumber + 1) * 10000)
    file = open("pubmed_" + start + "_" + end + ".xml", "r")
    count = 0
    found = 0
    for line in file:
        line = line.rstrip()
        if line.find(word) != -1:
            found = 1
        if found == 1:
            if count == 10:
                print
                count = 0
                found = 0
                i += 1
                if i == 10:
                    break
            else:
                print line
                count += 1
    if found == 1:
        i += 1
        print
    file.close()